package org.centsuse.intention_spring.invention.utils;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

/**
 * 日期处理工具类
 */
public class DateUtils {
    private static final DateTimeFormatter DATE_FORMATTER =
            DateTimeFormatter.ofPattern("yyyy-MM-dd");

    // 获取当前日期字符串
    public static String getCurrentDate() {
        return LocalDate.now().format(DATE_FORMATTER);
    }

    /**
     * 计算当前日期和未来指定天数后的日期
     * @param days 从当前日期起的天数（默认7天）
     * @return 包含当前日期和未来日期的字符串数组
     *
     * 使用示例：
     * String[] dates = getCurrentAndFutureDates();
     * System.out.println("当前日期: " + dates[0]);
     * System.out.println("7天后日期: " + dates[1]);
     */
    public static String[] getCurrentAndFutureDates(int days) {
        LocalDate currentDate = LocalDate.now();
        LocalDate futureDate = currentDate.plusDays(days);

        return new String[] {
                currentDate.format(DATE_FORMATTER),
                futureDate.format(DATE_FORMATTER)
        };
    }

    // 重载方法支持默认参数
    public static String[] getCurrentAndFutureDates() {
        return getCurrentAndFutureDates(7);
    }

    public static void main(String[] args) {
        // 测试用例
        System.out.println("当前日期: " + getCurrentDate());

        String[] dates = getCurrentAndFutureDates();
        System.out.println("\n默认7天:");
        System.out.println("当前日期: " + dates[0]);
        System.out.println("未来日期: " + dates[1]);

        String[] customDates = getCurrentAndFutureDates(3);
        System.out.println("\n自定义3天:");
        System.out.println("当前日期: " + customDates[0]);
        System.out.println("未来日期: " + customDates[1]);
    }
}
